public class Text3 {
    //第三题： 孩子们的游戏
    public int LastRemaining_Solution (int n, int m) {
        // write code here

        int p = 0;
        for(int i  =2; i <= n; i++) {
            p = (p+m) %i;
        }
        return p;
    }
}
